home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / E-G / GetDANames 1.2.cpt / GetDANames 1.2 / card_3972.txt < prev    next >
Text File  |  1989-02-26  |  9KB  |  342 lines

  1. -- card: 3972 from stack: in.2
  2. -- bmap block id: 4348
  3. -- flags: 0000
  4. -- background id: 2812
  5. -- name: Try it out!
  6. ----- HyperTalk script -----
  7. on openCard
  8.   hide card field "Button ID"
  9. end openCard
  10.  
  11. on closeCard
  12.  
  13.   -- If there is already a DA-launching button on this card,
  14.   -- then delete it
  15.   if card field "Button ID" is not empty and the number of card buttons > 3 then
  16.     set cursor to 4
  17.     set lockScreen to true
  18.     choose button tool
  19.     -- Get the ID of the button we've created (which has been
  20.     -- placed in the hidden card field, "Button ID"), and use
  21.     -- this ID to locate and delete the button.
  22.     click at the loc of -- card button ID (item 1 of card field "Button ID")
  23.     -- doMenu "Clear button"
  24.     choose browse tool
  25.     set lockScreen to false
  26.   end if
  27.  
  28.   put empty into card field "Button ID"
  29.   put empty into card field "Sample DA menu"
  30.   put empty into card field "Show DA names"
  31.  
  32. end closeCard
  33.  
  34.  
  35. -- part 1 (field)
  36. -- low flags: 01
  37. -- high flags: 0000
  38. -- rect: left=369 top=250 right=304 bottom=499
  39. -- title width / last selected line: 0
  40. -- icon id / first selected line: 0 / 0
  41. -- text alignment: 0
  42. -- font id: 0
  43. -- text size: 12
  44. -- style flags: 0
  45. -- line height: 16
  46. -- part name: Sample DA menu
  47. ----- HyperTalk script -----
  48. on mouseUp
  49.  
  50.   -- Find out which line the user has clicked on
  51.   get clickline()
  52.   put it into theLineClickedOn
  53.  
  54.   -- Highlight the line
  55.   select line theLineClickedOn of card field "Sample DA menu"
  56.  
  57.   -- Clear the highlighting
  58.   wait 20 ticks
  59.   click at 0,0
  60.  
  61.   -- Put the contents of this line into a container
  62.   put line theLineClickedOn of card field "Sample DA menu" into theDAtoLaunch
  63.  
  64.   -- If this container contains the valid name of a DA,
  65.   -- then launch that DA
  66.   if theDAtoLaunch is not empty then
  67.     if theDAtoLaunch contains "‚Ķ" then
  68.       answer "This DA name is truncated--I can't launch it." with "Sorry"
  69.     else
  70.       doMenu theDAtoLaunch
  71.     end if
  72.   end if
  73.  
  74. end mouseUp
  75.  
  76. -- The following function is taken directly from Apple's
  77. -- documentation for the HyperCard 1.2 release
  78.  
  79. --function clickLine returns the line of the target field
  80. --over which the mouse was clicked.  It allows 4 pixels under the
  81. --baseline for the psychological effect of descenders.
  82.  
  83. function clickLine
  84. return ((the mouseV - item 2 of the rect of the target-4) div the textheight of the target) + 1
  85. end clickLine
  86.  
  87.  
  88.  
  89. -- part 2 (button)
  90. -- low flags: 00
  91. -- high flags: 8002
  92. -- rect: left=20 top=116 right=137 bottom=116
  93. -- title width / last selected line: 0
  94. -- icon id / first selected line: 0 / 0
  95. -- text alignment: 1
  96. -- font id: 21
  97. -- text size: 12
  98. -- style flags: 0
  99. -- line height: 16
  100. -- part name: getDANames
  101. ----- HyperTalk script -----
  102. on mouseUp
  103.  
  104.   set cursor to 4 -- watch cursor
  105.   put empty into card field "Show DA names"
  106.  
  107.   -- The GetDANames XCMD will put the names of the DAs in the
  108.   -- Apple menu in the form of a comma-delimited item list
  109.   -- into the container, "namesOfDAs"
  110.   GetDANames
  111.  
  112.   -- Put the contents of this container into the card field
  113.   put namesOfDAs into card field "Show DA names"
  114.  
  115. end mouseUp
  116.  
  117.  
  118. -- part 3 (field)
  119. -- low flags: 00
  120. -- high flags: 0007
  121. -- rect: left=134 top=116 right=185 bottom=499
  122. -- title width / last selected line: 0
  123. -- icon id / first selected line: 0 / 0
  124. -- text alignment: 0
  125. -- font id: 21
  126. -- text size: 12
  127. -- style flags: 0
  128. -- line height: 16
  129. -- part name: Show DA names
  130.  
  131.  
  132. -- part 4 (button)
  133. -- low flags: 00
  134. -- high flags: 8002
  135. -- rect: left=238 top=229 right=249 bottom=339
  136. -- title width / last selected line: 0
  137. -- icon id / first selected line: 0 / 0
  138. -- text alignment: 1
  139. -- font id: 21
  140. -- text size: 12
  141. -- style flags: 0
  142. -- line height: 16
  143. -- part name: Make a DA list
  144. ----- HyperTalk script -----
  145. on mouseUp
  146.  
  147.   set cursor to 4 -- watch cursor
  148.  
  149.   -- Clear the contents of the sample DA menu
  150.   put empty into card field "Sample DA menu"
  151.  
  152.   -- Put the list of the names of the DAs in the apple menu into
  153.   -- the container, "namesOfDAs"
  154.   GetDANames
  155.  
  156.   -- Use James L. Paul's DoList (ListManager) routine to display a list
  157.   -- of DAs, from which one can select a DA to launch
  158.   DoList "Select","Cancel",namesOfDAs,one
  159.  
  160.   -- If the user selected a DA name, then launch that DA
  161.   if the result is not empty then
  162.  
  163.     put item 2 of the result into theDAtoOpen
  164.     doMenu theDAtoOpen
  165.  
  166.     -- Otherwise put the names of the first three DAs into the
  167.     -- sample menu to the right
  168.   else
  169.  
  170.     -- Put the first three names of DAs into the sample DA menu
  171.     -- next to this button
  172.  
  173.     -- Make a sample DA menu with up to three choices, depending
  174.     -- on the number of DAs in the Apple menu
  175.     -- (The numberOfDAs function is in the stack script)
  176.     if numberOfDAs() > 3 then put 3 into theNumberOfDAs
  177.  
  178.     -- Put the names of these DAs into the sample menu
  179.     -- (The truncateAt15Chars function is in the stack script)
  180.     repeat with theCount = 1 to theNumberOfDAs
  181.       put truncateAt15Chars(item theCount of namesOfDAs) into line theCount of card field "Sample DA menu"
  182.     end repeat
  183.  
  184.   end if
  185.  
  186. end mouseUp
  187.  
  188.  
  189.  
  190. -- part 5 (button)
  191. -- low flags: 00
  192. -- high flags: 8002
  193. -- rect: left=20 top=229 right=249 bottom=126
  194. -- title width / last selected line: 0
  195. -- icon id / first selected line: 0 / 0
  196. -- text alignment: 1
  197. -- font id: 21
  198. -- text size: 12
  199. -- style flags: 0
  200. -- line height: 16
  201. -- part name: Make a DA button
  202. ----- HyperTalk script -----
  203. on mouseUp
  204.  
  205.   -- Display the watch cursor
  206.   set cursor to 4
  207.  
  208.   --  Get the names of the DAs, putting these into the container
  209.   --  "namesOfDAs" in item list format
  210.   getDANames
  211.  
  212.   --  Ask for the name of a desk accessory
  213.   --  See James L. Paul's "HyperList" stack for more
  214.   --  information about the DoList command
  215.   DoList "Select","Cancel",namesOfDAs,one
  216.  
  217.   --  If a choice was made, then put the name of the item chosen
  218.   --  into a temporary variable; otherwise exit this script
  219.   if the result > 0 then
  220.     put item 2 of the result into daName
  221.   else
  222.     exit mouseUp
  223.   end if
  224.  
  225.   --  "Freeze" the screen while a button is being made and displayed
  226.   set lockScreen to true
  227.  
  228.   --  If there is already a DA-launching button on this card,
  229.   --  then delete it
  230.   if card field "Button ID" is not empty and the number of card buttons > 3 then
  231.     put item 1 of card field "Button ID" into buttonID
  232.     choose button tool
  233.     click at the loc of card button ID buttonID
  234.     doMenu "Clear button"
  235.     choose browse tool
  236.   end if
  237.  
  238.   --  Make the new button
  239.   doMenu "New Button"
  240.   hide button "New Button"
  241.   put daName into nameOfButton
  242.   set name of button "New Button" to nameOfButton
  243.  
  244.   --  Use the suitcase icon for DAs which has been pasted into
  245.   --  this stack, and given the name "DA suitcase"
  246.   set icon of button nameOfButton to "DA suitcase"
  247.   set style of button nameOfButton to shadow
  248.   put 135 into leftSide
  249.   put 235 into topSide
  250.   set rect of button nameOfButton to leftSide, topSide, leftSide + 90, topSide + 60
  251.  
  252.   --  Store the button ID of the newly-created button, so
  253.   --  that it can be deleted later
  254.   put ID of button nameOfButton into card field "Button ID"
  255.  
  256.   --  Construct the script for the new button and place it
  257.   --  into the button's script
  258.   put "on mouseUp" & return into buttonScript
  259.   put "doMenu" && quote & daName & quote & Return after buttonScript
  260.   put "end mouseUp" & Return after buttonScript
  261.   set script of button nameOfButton to buttonScript
  262.  
  263.   --  Clean up things and flash the newly-created button
  264.   show button nameOfButton
  265.   choose browse tool
  266.   set lockScreen to false
  267.   repeat 2
  268.     set the hilite of button nameOfButton to true
  269.     set the hilite of button nameOfButton to false
  270.   end repeat
  271.  
  272. end mouseUp
  273.  
  274.  
  275. -- part 8 (field)
  276. -- low flags: 81
  277. -- high flags: 0000
  278. -- rect: left=73 top=61 right=80 bottom=144
  279. -- title width / last selected line: 0
  280. -- icon id / first selected line: 0 / 0
  281. -- text alignment: 0
  282. -- font id: 3
  283. -- text size: 12
  284. -- style flags: 0
  285. -- line height: 16
  286. -- part name: Button ID
  287.  
  288.  
  289. -- part 32 (button)
  290. -- low flags: 00
  291. -- high flags: 0000
  292. -- rect: left=365 top=222 right=247 bottom=500
  293. -- title width / last selected line: 0
  294. -- icon id / first selected line: 0 / 0
  295. -- text alignment: 1
  296. -- font id: 0
  297. -- text size: 12
  298. -- style flags: 0
  299. -- line height: 16
  300. -- part name: Make sample DA menu
  301. ----- HyperTalk script -----
  302. on mouseUp
  303.  
  304.   -- Clear out the last entries used
  305.   put empty into card field "Sample DA menu"
  306.  
  307.   -- Get the names of the DAs in the Apple menu
  308.   GetDANames
  309.  
  310.   -- Put the first three names of DAs into the sample DA menu
  311.   -- under this button
  312.  
  313.   -- Make a sample DA menu with up to three choices, depending
  314.   -- on the number of DAs in the Apple menu
  315.   -- (The numberOfDAs function is in the stack script)
  316.   if numberOfDAs() > 3 then put 3 into theNumberOfDAs
  317.  
  318.   -- Put the names of these DAs into the sample menu
  319.   -- (The truncateAt15Chars function is in the stack script)
  320.   repeat with theCount = 1 to theNumberOfDAs
  321.     put truncateAt15Chars(item theCount of namesOfDAs) into line theCount of card field "Sample DA menu"
  322.   end repeat
  323.  
  324. end mouseUp
  325.  
  326.  
  327.  
  328.  
  329.  
  330. -- part contents for card part 3
  331. ----- text -----
  332. Suitcase II,Acta,Alarm Clock,Art Grabber+‚Ñ¢,Async AppleTalk,Calculator,CD Remote,Chooser,Control Panel,DeskDraw‚Ñ¢,DeskPaint‚Ñ¢ ,DiskTop ------>,Display RLE Image,Guidance,HD Partition,HyperDA,Icon Maker 2.1,Key Caps,McSink------>,QuickMail,SmartScrap‚Ñ¢,Thunder
  333.  
  334. -- part contents for card part 1
  335. ----- text -----
  336. Suitcase II
  337. Acta
  338. Alarm Clock
  339.  
  340. -- part contents for card part 8
  341. ----- text -----
  342. 36